﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace QLThuVien
{
    public partial class frSachConTrongThuVien : Form
    {
        public frSachConTrongThuVien()
        {
            InitializeComponent();
        }

        private void frSachConTrongThuVien_Load(object sender, EventArgs e)
        {
            KetNoi.setconnect();
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter("SELECT *FROM SACH,TACGIA,LOAISACH,NGONNGU,NXB,SANGTAC,NHACUNGCAP,VITRI WHERE SACH.MASACH = SANGTAC.MASACH AND SANGTAC.MATACGIA=TACGIA.MATACGIA AND SACH.MALOAISACH=LOAISACH.MALOAISACH AND SACH.MANXB=NXB.MANXB AND SACH.MANGONNGU=NGONNGU.MANGONNGU AND SACH.MANCC=NHACUNGCAP.MANCC AND SACH.MAVT=VITRI.MAVT AND SACH.MASACH NOT IN ( SELECT SACH.MASACH FROM SACH,SACH_PHIEU WHERE SACH.MASACH = SACH_PHIEU.MASACH AND SACH_PHIEU.NGAYTRA IS NULL)", KetNoi.scn);
            da.Fill(dt);
            DataColumn dc = new DataColumn();
            dt.Columns.Add(dc);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                listView1.Items.Add(dt.Rows[i]["MASACH"].ToString(), 1);
                listView1.Items[i].SubItems.Add(dt.Rows[i]["TENSACH"].ToString());
                listView1.Items[i].SubItems.Add(dt.Rows[i]["TENLOAISACH"].ToString());
                listView1.Items[i].SubItems.Add(dt.Rows[i]["HOTEN"].ToString());
                listView1.Items[i].SubItems.Add(dt.Rows[i]["TENNXB"].ToString());
                listView1.Items[i].SubItems.Add(dt.Rows[i]["NAMXUATBAN"].ToString());
                listView1.Items[i].SubItems.Add(dt.Rows[i]["LANXUATBAN"].ToString());
                listView1.Items[i].SubItems.Add(dt.Rows[i]["NGONNGU"].ToString());
                listView1.Items[i].SubItems.Add(dt.Rows[i]["GIA"].ToString());
                listView1.Items[i].SubItems.Add(dt.Rows[i]["TENNCC"].ToString());
                listView1.Items[i].SubItems.Add(dt.Rows[i]["MAVT"].ToString());
            }
        }
    }
}
